<?php
/*
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
//公众号列表。需要展现的数据：公众号名称，所属用户，公众号logo，用户有效期（如果有）
defined('BY_JYA') or exit('error');
$_RQ['op']=$_RQ['op']?$_RQ['op']:'list';
$return=array();
if(!$_SESSION['isfounder']){
	exi('您无权访问！','error','/index/');
}
if($_RQ['op']=='list'){
	$params=array();
	if(!empty($_RQ['title'])){
		$params['title like']='%'.trim($_RQ['title']).'%';
		$return['params']['title']=$_RQ['title'];
	}
	if($_RQ['stop']){
		$params['stop']=intval($_RQ['stop']);
		$return['params']['stop']=$_RQ['stop'];
	}
	if($_RQ['uniacid']){
		$params['uniacid']=intval($_RQ['uniacid']);
		$return['params']['uniacid']=$_RQ['uniacid'];
	}
	$orderby='uniacid desc';
	$pindex = max(1, intval($_RQ['page']));
	$psize = 10;
	$total='';
	$list=pdo_getslice('core_accounts',$params,array($pindex,$psize),$total,$fields,'',$orderby);
	foreach($list as &$item){
		$item['endtime_show']=$item['endtime']?date('Y/m/d',$item['endtime']):'长期有效';
		$item['username']=pdo_getcolumn('core_users',array('id'=>$item['uniacid']),'name')?:'无';
		$item['createtime']=pdo_getcolumn('core_users',array('id'=>$item['uniacid']),'createtime');
		if($_SESSION['user']['isonesys']){
			$item['isonesys']=1;
		}else{
			$item['isonesys']=0;
		}
	}
	$return['list']=$list;
	$totalpage=ceil($total/$psize);
	$totalpage=intval($totalpage);
	$return['totalpage'] =$totalpage;
	$return['params']['page'] =$pindex;
	$return['statuss']=array(
		'0'=>'正常',
		'1'=>'待审核',
		'2'=>'已禁止',
	);
	$return['stops']=array(
		'0'=>'正常',
		'1'=>'被禁止',
	);
	$htmls=array(
		'type'=>'list',
		'list'=>array('data'=>'list','psize'=>$psize,'total'=>$total,'key'=>'uniacid','edit'=>false,'del_one'=>false,'delall'=>false,'list'=>array(
			array('name'=>'logo','title'=>'店铺LOGO','type'=>'image'),
			array('name'=>'title','title'=>'店铺名称','type'=>'string'),
			array('name'=>'stop','title'=>'站点状态','type'=>'radio','options'=>'stops'),
			array('name'=>'username','title'=>'主管理员','type'=>'string'),
			array('name'=>'createtime','title'=>'创建时间','type'=>'time'),
			array('name'=>'endtime_show','title'=>'到期时间','type'=>'string'),
		),'action'=>array(
			array('op'=>'look','title'=>'详情','type'=>'modal'),
		)),
		'search'=>array(
			array('type'=>'string','width'=>15,'name'=>'uniacid','title'=>'用户ID'),
			array('type'=>'radio','width'=>15,'name'=>'stop','title'=>'状态','options'=>'stops'),
		),
	);
	$return['htmls']=$htmls;
	$tabs=array(
		array('op'=>'list','title'=>'店铺列表')
	);
	set_html('tabs',$tabs);
	exi($return);
}
if($_RQ['op']=='look'){
		$uniacid=intval($_RQ['uniacid']);
		if(!$uniacid){
			exi('请先选择店铺！','error');
		}
		$item=pdo_get('core_accounts',array('uniacid'=>$uniacid));
		$return['item']=$item;
		$return['htmls']=array(
			'type'=>'look',
			'desc'=>'店铺详情',
			'look'=>array(
				array('type'=>'string','title'=>'站点名称','name'=>'title', 'help'=>'' ),
				array('type'=>'string','title'=>'站点描述','name'=>'desc', 'help'=>'' ),
				array('type'=>'image','title'=>'站点图标','name'=>'logo', 'help'=>'' ),
				array('type'=>'image','title'=>'站点二维码','name'=>'ewm', 'help'=>'可填写微信公众号二维码，用于微官网关注扫码！' ),
				array('type'=>'image','title'=>'小程序二维码','name'=>'wxapp_ewm', 'help'=>'可填写小程序二维码，用于小程序产品宣传！' ),
				array('type'=>'image','title'=>'宣传二维码','name'=>'xiu_ewm', 'help'=>'可填写H5场景秀二维码，用于产品宣传！' ),
				array('type'=>'string','title'=>'宣传URL','name'=>'xiu_url', 'help'=>'可填写H5场景秀URL，用于产品宣传！' ),
				array('type'=>'string','title'=>'联系人','name'=>'lxr' ),
				array('type'=>'string','title'=>'联系电话','name'=>'phone' ),
				array('type'=>'string','title'=>'QQ','name'=>'qq' ),
				array('type'=>'string','title'=>'邮箱','name'=>'mail' ),
				array('type'=>'string','title'=>'公司名称','name'=>'cname' ),
				array('type'=>'string','title'=>'ICP备案号','name'=>'icp' ),
			),
		);
		exi($return);	
}
?>